<template>
  <view class="bottombox">
    <view class="left" @tap="toHome">
      <image src="../static/homeOff.svg" class="imgPublic" alt="" />
      <text class="title">首页</text>
    </view>
    <view class="left" @tap="saoyisao">
      <image src="../static/images/sweep.png" class="sweep" alt="" />
    </view>
    <view class="left" @tap="toMy">
      <image src="../static/myOff.svg" class="imgPublic" alt="" />
      <text class="title">我的</text>
    </view>
  </view>
</template>

<script>
import { router } from "@/router/index.js";
export default {
  props: ["type"],
  data() {
    return {};
  },

  methods: {
    // 首页
    toHome() {
      uni.reLaunch({
        url: "/pages/home/index",
      });
    },
    // 我的
    toMy() {
      uni.reLaunch({
        url: "/pages/mine/mine",
      });
    },
    saoyisao() {
      // router.toPage({
      //   path: "/pages/znxj/xjrw/smrw",
      //   params: {
      //     id: 628,
      //   },
      // });
      // return;
      // 只允许通过相机扫码
      uni.scanCode({
        success: function (res) {
          let data = "";
          try {
            data = JSON.parse(res.result);
          } catch (e) {
            data = res.result;
          }
          if (data instanceof Object) {
            if (data.type == "双重预防") {
              router.toPage({
                path: "/pages/yhpc/pcjh/pcrwsm",
                params: {
                  id: data.id,
                },
              });
            } else if (data.type == "巡检") {
              router.toPage({
                path: "/pages/znxj/xjrw/smrw",
                params: {
                  id: data.id,
                },
              });
            } else {
              uni.showToast({
                title: "未识别二维码",
              });
            }
          } else {
            uni.showToast({
              title: "未识别二维码",
            });
          }
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.bottombox {
  flex: none;
  height: 100rpx;
  background: #fff;
  display: flex;
  align-items: center;
  position: fixed;
  width: 100vw;
  bottom: 0;
  .imgPublic {
    width: 44rpx;
    height: 44rpx;
  }
  .sweep {
    width: 84rpx;
    height: 84rpx;
  }
  .title {
    color: #86909c;
    text-align: center;
    font-size: 20rpx;
    font-family: PingFang SC;
    font-style: normal;
    font-weight: 400;
    line-height: normal;
  }
}
.left {
  width: 33%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
</style>
